package homeword.personPassRiver;

public class Person {

    private String name;
    private Vehicles vehicles;

    public Person(String name, Vehicles vehicles) {
        this.name = name;
        this.vehicles = vehicles;
    }

    public void passRiver() {
        //如果没船
        if (!(vehicles instanceof Boat)) {
            vehicles = VehicleFactory.getBoat();
        }
        vehicles.work();
    }
    public void passCommon() {
        if(!(vehicles instanceof Horse)){
            vehicles = VehicleFactory.getHorse();
        }
        vehicles.work();
    }
    //火焰山
    public void passMountain() {
        if (!(vehicles instanceof Aeroplane)){
            vehicles = VehicleFactory.getAeroplane();
        }
        vehicles.work();
    }


}
